package com.qf.android.sport.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.qf.android.sport.entity.Channels;
import com.qf.android.sport.fragment.news.PagerFragment;

import java.util.List;

/**
 * Created by wuruyuan on 2016/12/15.
 * 新闻ViewPager的适配器
 */

public class PagerAdapter extends FragmentPagerAdapter {
    private List<Channels> list;

    public PagerAdapter(FragmentManager fm, List<Channels> list) {
        super(fm);
        this.list = list;
    }

    @Override
    public Fragment getItem(int position) {
        return PagerFragment.getInstance(list.get(position).getName());
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getName();
    }

}
